/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo1021;
import java.sql.*;

/**
 *
 * @author Administrator
 */
public class InsertDemo {
    public static void main(String args[]){
        Connection conn=null;
        Statement stat=null;
       
        try{
        Class.forName("com.mysql.jdbc.Driver");//
        String url="jdbc:mysql://localhost:3306/st";
        conn=DriverManager.getConnection(url, "root", "");
        stat=conn.createStatement();
        String no="199908";
        String name="li";
        String insertsql1=
                "insert into students values('"+
                no+"','"+name+"',67,78,89)";
        String insertsql="insert into students values('"+
                "199908"+"','li',67,78,89)";
        int count=stat.executeUpdate
                (" insert into students values('199908','li',67,78,89)");
           System.out.println(count);
           if(count>0){
               System.out.println("更新成功");
           }else{
               System.out.println("更新失败");
           }
      
        }catch(ClassNotFoundException e){
            System.out.println(e.getMessage());
        }
        catch(SQLException e){
            System.out.println(e.getMessage());
            
        }
    }
    
}
